
import random
import pandas as pd
import pymysql
#建立数据库连接
import requests

# conn = pymysql.connect("127.0.0.1","root","123456","reptile",charset="utf8")
# #读取数据库表数据
# data = pd.read_sql("select http_https, ip,port from pr_ip",con=conn)
# #数据转化为列表
# x = list(data.http_https)
# y = list(data.ip)
# z = list(data.port)
#
# iplist= []
# for i in range(len(data)):
#     iplist.append('%s://%s:%s'%(x[i],y[i],z[i]))
#     proxy = '%s://%s:%s'%(x[i],y[i],z[i])
#     print('proxy=',proxy)
#     try:
#         res = requests.get("http://www.qq.com/", proxies=proxy, verify=False)
#     except Exception as error:
#         print("代理无法连接".format(error))
#         continue
#     else:
#         if res.status_code == 200:
#             # zhima["proxy"].append(proxy)
#             print('可以使用=',proxy)
#         else:
#             continue

# print(random.choice(iplist))

# def get_ip():
#     return random.choice(iplist)

# try:
#     res = requests.get("http://www.qq.com/", proxies='180.137.232.101:53281', verify=False)
# except Exception as error:
#     print("代理无法连接".format(error))
#
# else:
#     if res.status_code == 200:
#         # zhima["proxy"].append(proxy)
#         print('可以使用=')


# 125.64.96.21:8008
# 58.19.176.200:8080
# 219.139.158.59:8080
# 61.153.213.34:8080
# 122.224.33.10:80
# 121.8.126.90:8080
# 121.14.158.75:80
# 121.14.158.76:80